* stata version 15

* Study I: the 2014 analysis

use "/Users/davidbarker/Google Drive/Research/Facts and Premises/premises BJPOLS 2014 harvard dataverse.dta"

* First, we use factor analysis to create the outcome variables, the first of which is an overall policy ideology measure comprised of 16 items.
* Here are the 16 items and their alpha:
tab1 CC14_320e CC14_322_1 CC14_322_4 CC14_323_4 CC14_324_2 CC14_327 CC14_328 UML501_2 UML501_4 UML501_7 UML501_9 UML501_11 UML501_12 UML501_14 P005 iraqnotmistake
 alpha CC14_320e CC14_322_1 CC14_322_4 CC14_323_4 CC14_324_2 CC14_327 CC14_328 UML501_2 UML501_4 UML501_7 UML501_9 UML501_11 UML501_12 UML501_14 P005 iraqnotmistake
* here is the factor analysis:
factor  CC14_320e CC14_322_1 CC14_322_4 CC14_323_4 CC14_324_2 CC14_327 CC14_328 UML501_2 UML501_4 UML501_7 UML501_9 UML501_11 UML501_12 UML501_14 P005 iraqnotmistake, ml factors (1)
* now for the economic ideology factor:
alpha P005 UML501_7 UML501_4 CC14_324_2 UML501_11 UML501_14
factor P005 UML501_7 UML501_4 CC14_324_2 UML501_11 UML501_14, ml factors (1)
* now for the cultural ideology factor
alpha CC14_327 CC14_328 CC14_323_4 CC14_322_1 CC14_320e
factor CC14_327 CC14_328 CC14_323_4 CC14_322_1 CC14_320e, ml factors (1)
* now the security ideology factor
alpha iraqnotmistake UML501_2 UML501_12
* now we create the factor scores for each premise.  First, the one for whether human nature is benevolent or selfish
alpha P113 P114 P116 
factor P113 P114 P116, ml factors (1)

* now sanguinity-cynicism with respect to the possibility of achieving human progress:
alpha P108 P109 P110 prem_p107_wrldiswhatis
factor P108 P109 P110 prem_p107_wrldiswhatis, ml factors (1)

* now the stability-fragility of society:
alpha P101 P103 prem_p106_amerwayfine
factor P101 P103 prem_p106_amerwayfine, ml factors (1)

* These factor analyses were used to create the following variables (by using the predict command following each factor analysis): ideolissuesfactor1601 ideoleconfactor01 ideoculturefactor501 ideodefensefactor301 humanbadfctrnew1901 premprogskepticalfactor01 and premsocietyfragilefactor01
* in each case, we rescaled the variable to 0-1.

* now for the regression estimations. The first uses the 3-point ideological identification variable as the outcome variable
* and estimates using generalized ordered logit, focusing on the comparisons between predictions of being a liberal or a conservative, ignoring moderates
gologit2 ideo301 humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 white female age01 educ01 faminc01, cluster (cdid) or

* now for the overall ideology outcome variable
reg ideolissuesfactor1601 humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 white female age01 educ01 faminc01, cluster (cdid)
* now for the economic ideology outcome variable
reg ideoleconfactor01 humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 white female age01 educ01 faminc01, cluster (cdid)
* now for the culture war ideology model
reg ideoculturefactor501 humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 white female age01 educ01 faminc01, cluster (cdid)
* now for the security/defense ideology model:
reg ideodefensefactor301 humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 white female age01 educ01 faminc01, cluster (cdid)
* now for the overall ideology outcome variable, with missing values of that variable imputed

impute ideolissuesfactor1601 white female age01 educ01 faminc01 ideo301 pid3clean01, generate (ideoissuefactr1601imputedrep)

reg ideoissuefactr1601imputedrep humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 white female age01 educ01 faminc01, cluster (cdid)
reg ideoissuefactr1601imputedrep humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 white female age01 educ01 faminc01, cluster (cdid)
* now for all of the models with party ID also included as a control
gologit2 ideo301 humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 pid3clean01 white female age01 educ01 faminc01, cluster (cdid) or
reg ideolissuesfactor1601 humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 pid3clean01 white female age01 educ01 faminc01, cluster (cdid)
reg ideoleconfactor01 humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 pid3clean01 white female age01 educ01 faminc01, cluster (cdid)
reg ideoculturefactor501 humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 pid3clean01 white female age01 educ01 faminc01, cluster (cdid)
reg ideodefensefactor301 humanbadfctrnew1901 premprogskepticalfactor01 premsocietyfragilefactor01 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 pid3clean01 white female age01 educ01 faminc01, cluster (cdid)


* now for the CFA model comparisons (SEM)

* first, the one we consider our theoretically derived model:

sem (humnature -> P113, ) (humnature -> P114, ) (humnature -> P116, ) (progress -> prem_p107_wrldiswhatis, ) (progress -> P108, ) (progress -> P109, ) (progress -> P110, ) (societyfragstable -> prem_p106_amerwayfine,) (societyfragstable -> P101, ) (societyfragstable -> P103, ) (valu_coopselfreli01) (valu_knowlfaith01) (valu_peaceprotect01) (valu_kinddiscip01) ( ideo301 ideolissuesfactor1601 <- humnature progress societyfragstable valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 white female age01 educ01 faminc01), latent (humnature progress societyfragstable ) method (mlmv) nocapslatent
estat gof, stats(indices)

* Next, an alternative model that does not differentiate the premises:
sem (humnature -> P113 P114 P116 prem_p107_wrldiswhatis P108  P109 prem_p106_amerwayfine P101 P103 ) (valu_coopselfreli01) (valu_knowlfaith01) (valu_peaceprotect01) (valu_kinddiscip01) ( ideo301 ideolissuesfactor1601 <- humnature valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 white female age01 educ01 faminc01), latent (humnature) method (mlmv) nocapslatent
estat gof, stats(indices)

*Next, a third alternative that treats all premises and values as part of one big value index:
 sem (humnature -> P113 P114 P116 prem_p107_wrldiswhatis P108  P109 prem_p106_amerwayfine P101 P103 valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01) ( ideo301 ideolissuesfactor1601 <- humnature white female age01 educ01 faminc01), latent (humnature) method (mlmv) nocapslatent
estat gof, stats(indices)

* NOW FOR THE FINAL STRUCTURAL EQUATION MODEL IN THE ONLINE APPENDIX, TREATING VALUES AS ENDOGENOUS

 sem (humnature -> P113, ) (humnature -> P114, ) (humnature -> P116, ) (progress -> prem_p107_wrldiswhatis, ) (progress -> P108, ) (progress -> P109, ) (progress -> P110, ) (societyfragstable -> prem_p106_amerwayfine,) (societyfragstable -> P101, ) (societyfragstable -> P103, ) (valu_coopselfreli01) (valu_knowlfaith01) (valu_peaceprotect01) (valu_kinddiscip01) ( ideo301 ideolissuesfactor1601 <- humnature progress societyfragstable valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 white female age01 educ01 faminc01) (valu_coopselfreli01 valu_knowlfaith01 valu_peaceprotect01 valu_kinddiscip01 valu_peaceprotect01 <- humnature progress societyfragstable white female age01 educ01 faminc01), latent (humnature progress societyfragstable ) cov( e.valu_knowlfaith01*e.valu_coopselfreli01 e.valu_knowlfaith01*e.valu_peaceprotect01 e.valu_knowlfaith01*e.valu_kinddiscip01 e.valu_coopselfreli01*e.valu_peaceprotect01 e.valu_coopselfreli01*e.valu_kinddiscip01 e.valu_peaceprotect01*e.valu_kinddiscip01 humnature*progress humnature*societyfragstable progress*societyfragstable e.ideo301*e.ideolissuesfactor1601) nocapslatent
estat gof, stats(indices) 
 
 

 
